package com.gw.smscheck.controller.sys;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.gw.smscheck.entity.sys.Log;
import com.gw.smscheck.service.sys.LogService;
import com.gw.smscheck.util.ResultConversion;
import com.gw.smscheck.util.ResultObj;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Log管理
 * 
 * @author wjy
 * @date 2018年08月13日
 */
@Controller
@RequestMapping("/logController")
@Api(description="【日志接口】")
public class LogController {
	@Autowired
	private LogService logService;


	/**
	 * 查询所有
	 *
	 * @return
	 */
	@ApiOperation(value="查询所有", notes="查询所有")
	@RequestMapping(value = "/findAll", method = { RequestMethod.GET })
	@ResponseBody
	public String findAll() {
		List<Log> list = logService.findAll();
		return JSON.toJSONString(list);
	}
	/**
	 * 分页查询
	 * @param log
	 * @return
	 */
	@ApiOperation(value="分页查询", notes="分页查询")
	@RequestMapping(value = "/pageSelect", method = { RequestMethod.POST })
	@ResponseBody
	public String pageSelect(Log log) {
		PageInfo<Log> pageInfo = logService.pageSelect(log);
		return ResultConversion.ToEasyUIDataGrid(pageInfo).toJSONString();
	}
	/**
	 * 通过id获取
	 * @param
	 * @return
	 */
	@ApiOperation(value="通过id获取", notes="通过id获取")
	@RequestMapping(value = "/findById", method = { RequestMethod.POST})
	@ResponseBody
	public String findById(Log dto){
		return ResultObj.successResultObj(logService.findById(dto.getId()));
	}
}

